package com.example.tests;

import org.testng.annotations.Test;

import com.example.fw.Folders;

import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;

public class FolderCreationTests extends TestBase {

	
	@Test
	public void testFolderCreation(){
		String folder = "newfolderiouy";
		Folders oldFolders =app.getFolderHelper().getFolders(); 
		assertThat(app.getFolderHelper().createFolder(folder), is(nullValue()));
		Folders newFolders =app.getFolderHelper().getFolders();
		assertThat(newFolders, equalTo(oldFolders.withAdded(folder)));
	}
	
	@Test
	public void testVariousFoldersCreation(){
		String folderName1 = "newfolder1";
		String folderName2 = "newfolder2";
		Folders oldFolders =app.getFolderHelper().getFolders(); 
		assertThat(app.getFolderHelper().createFolder(folderName1), is(nullValue()));
		Folders newFolders =app.getFolderHelper().getFolders();
		assertThat(newFolders, equalTo(oldFolders.withAdded(folderName1)));
		assertThat(app.getFolderHelper().createFolder(folderName2), is(nullValue()));
		Folders newFolders2 =app.getFolderHelper().getFolders();
		assertThat(newFolders2, equalTo(oldFolders.withAdded(folderName1).withAdded(folderName2)));
	}
	@Test
	public void testFoldersWithSameNameCreation(){
		String folderName = "newfolder3";
		Folders oldFolders =app.getFolderHelper().getFolders(); 
		assertThat(app.getFolderHelper().createFolder(folderName), is(nullValue()));
		Folders newFolders =app.getFolderHelper().getFolders();
		assertThat(newFolders, equalTo(oldFolders.withAdded(folderName)));
		assertThat(app.getFolderHelper().createFolder(folderName), is(not(nullValue())));
		Folders newFolders2 =app.getFolderHelper().getFolders();
		assertThat(newFolders2, equalTo(oldFolders.withAdded(folderName)));
	}

}
